#!/bin/sh
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
tinyoslibdir=$libdir/tinyos

jni=`tos-locate-jre --jni`
if [ $? -ne 0 ]; then
  echo "Java not found, not installing JNI code"
  exit 1
fi

if [ -x /bin/cygwin1.dll ]; then
  bits=32
  java=`tos-locate-jre --java`
  if [ $? -ne 0 ]; then
    echo "java command not found - assuming 32 bits"
  elif file -L "$java/java" | grep -qe '64-bit\|x86-64'; then #java7 on windows7 only prints x86-64
    bits=64
  fi
  echo "Installing $bits-bit Java JNI code in $jni ... "
  for lib in $tinyoslibdir/*-$bits.@JNISUFFIX@; do
    realname=`basename $lib | sed -e s/-$bits\.@JNISUFFIX@/.@JNISUFFIX@/`
    @INSTALLJNI@ $lib "$jni/$realname" || exit 1
  done
else
  echo "Installing Java JNI code in $jni ... "
  for lib in $tinyoslibdir/*.@JNISUFFIX@; do
    @INSTALLJNI@ $lib "$jni" || exit 1
  done
fi
